package com.mrzhou.thread.created;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.FutureTask;

/**
 * @author qiang.zhou
 */
@Slf4j
public class MainThread {

    private static final Logger logger =  LoggerFactory.getLogger(MainThread.class);

    public static void main(String[] args) throws Exception {
        logger.info("Main Running......");


        // 使用Thread创建线程实例
        ExtendsThread extendsThread = new ExtendsThread();
        extendsThread.start();

        // 使用Runnable创建线程实例
        ImplementsThread runnable = new ImplementsThread();
        Thread implThread = new Thread(runnable);
        implThread.start();

        FutureTask<Integer> task = new FutureTask<>(() -> {
            Thread.sleep(2000);
            return 200;
        });
        new Thread(task).start();
        log.info("Main函数执行完成 {}", task.get());
    }

}
